package com.tangerine.servicios;

import java.sql.SQLException;
import com.tangerine.bd.DbHandlerHistorial;
import com.tangerine.entidades.Historial;
import com.tangerine.entidades.Poi;

public class ServicioHistorial {
	
	public void insertarHistorial(Poi auxPoi) {
		int iCantReg = 0;
		Historial auxHistorial = new Historial();
		DbHandlerHistorial dhHistorial = new DbHandlerHistorial();
		
		auxHistorial.setIdPoi(auxPoi.getIdPoi());
		
		try {
			iCantReg = dhHistorial.existeHistorial(auxHistorial);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		if(iCantReg == 0)
		{
			try {
				dhHistorial.insertarHistorial(auxHistorial);		
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		dhHistorial = null;
	}
	
	public void eliminarHistorial() {
		
		DbHandlerHistorial dhHistorial = new DbHandlerHistorial();
		
		try {
			dhHistorial.eliminarHistorial();	
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		dhHistorial = null;
	}
}